<template>
    <rx-layout>
        <div slot="left" style="width:220px" showButton="true"  v-if="!curApp.appId">
            <a-directory-tree   @select="handleSelect" defaultExpandAll >
                <a-tree-node v-for="app in appList" :key="app.appId" :title="app.clientName"/>
            </a-directory-tree>
            <v-contextmenu ref="contextmenu" v-if="false">
                <v-contextmenu-item @click="addApp">{{i18n('list.addApp','新增应用')}}</v-contextmenu-item>
                <v-contextmenu-item @click="editApp">{{i18n('list.editApp','编辑应用')}}</v-contextmenu-item>
                <v-contextmenu-item @click="delApp">{{i18n('list.delApp','删除应用')}}</v-contextmenu-item>
            </v-contextmenu>
        </div>
        <div slot="center">
            <rx-fit>
                <div slot="toolheader" border="false" foldbtn="false">
                    <div class="table-page-search-wrapper" v-if="showSearch===true">
                        <a-form layout="inline">
                            <a-row :gutter="24">
                                <a-col :span="8">
                                    <a-form-item :label="i18n('form.menuName','菜单名称')">
                                        <a-input v-model="queryParam.Q_name__S_LK"/>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="8">
                                    <a-form-item :label="i18n('form.menuKey','标识键')">
                                        <a-input :placeholder="i18n('form.menuKey','标识键','input')" v-model="queryParam.Q_menu_key__S_LK"/>
                                    </a-form-item>
                                </a-col>
                                <a-col :span="8">
                                  <span class="table-page-search-submitButtons">
                                    <a-button @click="this.fetch" type="primary">{{$ti18('rxList.searchBtn','查询')}}</a-button>
                                    <a-button @click="() => queryParam = {}" style="margin-left: 8px">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                                  </span>
                                </a-col>
                            </a-row>
                        </a-form>
                    </div>
                    <div class="table-operator">
                        <a-button @click="handleNew" icon="plus" type="primary">{{$ti18('rxList.add','新增')}}</a-button>
                        <a-tooltip  placement="bottomLeft" :title="i18n('list.transferTip','选中父菜单，会默认把其下级菜单一起转移；如果选中父菜单再选中其下级菜单，一起选中的菜单转移后会处于同级')" >
                            <a-button  @click="transferAppMenus" icon="swap" type="primary">{{i18n('list.transferMenuBtn','转移菜单')}}</a-button>
                        </a-tooltip>
                        <a-button type="primary" @click="openMenuStyle" v-if="isApp">菜单风格</a-button>
                        <a-dropdown v-if="removeEnable && selectedRowKeys.length > 0">
                            <a-button type="danger" icon="delete" @click="delByIds(selectedRowKeys)">{{$ti18('rxList.delBtn','删除')}}</a-button>
                        </a-dropdown>
                        <a-button type="primary"
                                  v-if="selectedRowKeys.length > 0"
                                  icon="switcher" @click="changeExport(exportConf)">
                            {{$ti18('rxList.changeExport','切换导出')}}
                        </a-button>

                    </div>
                </div>
                <rx-grid
                    class="rx-tree-title"
                    ref="table"
                    :bordered="isBorder"
                    :allowRowSelect="true"
                    :multiSelect="true"
                    :columns="columns"
                    :defaultPageSize="20"
                    :dataSource="menuData"
                    :pageSizeOptions="['10','20','30','40']"
                    id-field="id"
                    :show-page="false"
                    @selectChange="onSelectChange"
                >
                    <span slot="exportApp">
                         {{ exportI18n('export.isExport','导出') }}
                        <export-app/>
                    </span>
                    <div slot="name" class="rx-table-row-icon" slot-scope="{text,record}">
                      <span class="rx-tree-icon" v-if="record.iconPc">
                        <a-icon v-if="!record.iconPc.includes('type')" :type="record.iconPc"></a-icon>
                        <my-icon v-else-if="customArr.includes(JSON.parse(record.iconPc).type)"
                                 :type="JSON.parse(record.iconPc).icon"></my-icon>
                        <a-icon v-else="JSON.parse(record.iconPc).type" :type="JSON.parse(record.iconPc).icon"></a-icon>
                      </span>
                        <div class="rx-tree-title">{{ $i18(text,'菜单名称') }}</div>
                    </div>

                    <span slot="menuType" slot-scope="{text}">
                        <a-tag :color="menuTypeMap[text].color">
                          <span>{{menuTypeMap[text].text}}</span>
                        </a-tag>
                    </span>

                    <span slot="visible" slot-scope="{text}">
                        {{ getStatusFilter(text) }}
                    </span>
                    <span slot="isExport" slot-scope="{ text, record }">
                        <a-tag :color="text == 1 ? 'green' : 'red'">
                            <span>{{ text == 1 ? exportI18n('export.yes','是') : exportI18n('export.no','否') }}</span>
                        </a-tag>
                    </span>
                    <span slot="action" slot-scope="{ text, record }" class="actionIcons">
                        <span @click.stop="handleEdit(record)" v-if="record.menuType!='I'">{{$ti18('rxList.editBtn','编辑')}}</span>
                        <span @click="openApiEdit(record)" v-if="record.menuType=='I'">{{$ti18('rxList.editBtn','编辑')}}</span>
                        <span @click.stop="delByIds([record.id])">{{$ti18('rxList.delBtn','删除')}}</span>
                        <span @click.stop="handleAdd(record)" :title="i18n('list.addSubMenu','新增子菜单')" v-if="record.menuType=='C'">{{i18n('list.addSubMenu','新增子菜单')}}</span>
                        <span @click.stop="transportOneTo(record)">{{i18n('list.transferTo','转移')}}</span>
                        <span @click.stop="interfaceDefine(record)" v-if="record.menuType!='I'">{{i18n('list.interfaceDefine','接口定义')}}</span>
                        <span @click="setExport(record,exportConf)">{{record.isExport == 1 ? exportI18n('export.noExport','不导出') : exportI18n('export.exported','导出')}}</span>
<!--                        <span @click.stop="setInstMenu(record)" title="机构个性化配置">机构个性化配置</span>-->
                    </span>
                </rx-grid>
            </rx-fit>
            <a-drawer
                wrapClassName="menuDrawer"
                :title="drawerTitle"
                placement="right"
                :closable="true"
                @close="onClose"
                :visible="drawerVisible"
                :width="drawerWidth"
            >
                <template v-if="menuShow" class="menu01">
                    <rx-fit>
                        <div slot="toolfooter" align="right">
                            <div class="footerToolbar">
                                <a-button :loading="confirmLoading" @click="handleSubmit" type="primary">{{$ti18('rxForm.commitBtn','提交')}}</a-button>
                                <a-button @click="resetForm">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                            </div>
                        </div>
                        <div style="padding-bottom: 20px;padding-right: 24px">
                            <a-form :form="form">
                                <a-form-item style="display:none">
                                    <a-input v-decorator="['id']"/>
                                    <a-input v-decorator="['parentId']"/>
                                </a-form-item>

                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.appId','应用')"
                                    v-if="!curApp.appId"
                                >
                                    <a-select v-decorator="['appId', {rules: [{ required: true, message: i18n('form.appId','应用','select') }]}]">
                                        <a-select-option :key="action.appId" v-for="(action) in appList">
                                            {{ $i18(action.clientName,'菜单名称') }}
                                        </a-select-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item v-if="parentName!=''"
                                             :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                             :label="i18n('form.owningMenu','所属菜单')"
                                >
                                    {{ $i18(parentName,'所属菜单') }}
                                </a-form-item>

                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.name','名称')"
                                >
                                    <rx-input-i18n v-show="menuNameShow" :key="menuKey"
                                                   v-decorator="['name', {rules: [{ required: true, message:i18n('form.menuName','菜单名称') }]}]"
                                                   :placeholder="i18n('form.menuName','菜单名称')" :isDecorator="true"
                                                   />
                                </a-form-item>
                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.menuRemark','菜单备注')"
                                >
                                    <rx-input-i18n v-if="menuNameShow" :key="menuKey" :placeholder="i18n('form.menuRemark','菜单备注')" :isDecorator="true"
                                                   v-model="remarks"/>
                                </a-form-item>

                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.menuKey','标识键')"
                                >
                                    <a-input
                                        v-decorator="['menuKey',{initialValue:'',rules: [
                                            { required: true, message: i18n('msa.menuKeyDesc','请输入动态菜单唯一键') },
                                            {pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:this.i18n2('form.str','不能以数字开头,不能包含【_-】以外的特殊字符！','input')}
                                            ]}]"
                                        :placeholder="i18n('form.keySush','如\'user\'')"/>
                                </a-form-item>


                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.menuType','菜单类型')"
                                >
                                    <a-radio-group @change="menuTypeChange"
                                                   v-decorator="['menuType', {initialValue:'C',rules: [{ required: true, message: i18n('form.menuType','请选择类型', 'select') }]}]">
                                        <a-radio :value="'C'">
                                            {{i18n('form.menu','菜单')}}
                                        </a-radio>
                                        <a-radio :value="'F'">
                                            {{i18n('form.button','按钮')}}
                                        </a-radio>
                                        <a-radio :value="'R'">
                                            {{i18n('form.router','路由')}}
                                        </a-radio>
                                    </a-radio-group>
                                </a-form-item>

                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.showType','访问方式')" v-if="isShowType"
                                >
                                    <a-radio-group @change="showTypeChange" :options="showTypeOptions"
                                                   v-decorator="['showType',{rules: [{initialValue:'URL', required: true, message: i18n('form.showType','访问方式','select') }]}]"/>
                                </a-form-item>
                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    v-show="curMenu.menuType!='F'&&(curMenu.showType=='URL'||curMenu.showType=='POP_WIN'||curMenu.showType=='NEW_WIN')"
                                    :label="i18n('form.settingType','配置类型')"
                                >
                                    <a-radio-group @change="settingTypeChange"
                                                   v-decorator="['settingType', {initialValue:'custom',rules: [{ required: true, message: i18n('form.settingType','配置类型') }]}]">
                                        <a-radio :value="'iframe'">
                                            IFrame
                                        </a-radio>
                                        <a-radio :value="'custom'">
                                            {{i18n('form.vueComponent','VUE组件')}}
                                        </a-radio>
                                        <template v-if="curApp && curApp.appId">
                                            <a-radio value="list">
                                                {{i18n('form.list','列表')}}
                                            </a-radio>
                                            <a-radio value="form">
                                                {{i18n('form.form','表单')}}
                                            </a-radio>
                                            <a-radio value="customPage">
                                                {{i18n('form.customPage','自定义页面')}}
                                            </a-radio>
                                            <a-radio value="calendar">
                                                {{i18n('form.calendar','日历视图')}}
                                            </a-radio>
                                            <a-radio value="bpm">
                                                {{i18n('form.bpm','流程')}}
                                            </a-radio>
                                        </template>
                                    </a-radio-group>

                                </a-form-item>

                                <a-form-item v-show="curMenu.menuType!='F' && curMenu.settingType=='custom'"
                                             :label-col="{ span: 9 }" :wrapper-col="{ span:9}"
                                             :label="i18n('form.componentPath','组件路径')"
                                >
                                    <a-input v-decorator="['component']"
                                             :placeholder="i18n('form.componentPath','组件路径')" style="width:90%;margin-right: 5px;"/>

                                    <a-tooltip>
                                        <template slot="title" style="width:400px;">
                                            {{i18n('msa.componentPathDesc','组件路径说明')}}
                                        </template>
                                        <a-icon type="question-circle-o"/>
                                    </a-tooltip>
                                </a-form-item>

                                <a-form-item
                                    v-show="curMenu.menuType!='F' && curMenu.settingType=='custom'"
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.componentParams','组件参数')"
                                >
                                    <a-input v-decorator="['params']" :placeholder="i18n('form.componentParams','组件参数','input')"/>
                                </a-form-item>

                                <a-form-item v-if="curMenu.menuType!='F' && curMenu.settingType=='iframe'"
                                             :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                             label="URL"
                                >
                                    <a-input v-decorator="['params']" :placeholder="i18n('form.url','URL','input')"/>
                                </a-form-item>
                                <a-form-item
                                    v-if="['URL','POP_WIN','NEW_WIN'].includes(curMenu.showType) && settingTypes.includes(curMenu.settingType)"
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.settingComponent','组件')"
                                >
                                    <rx-input-button  @click="openDialog($event, curMenu)" v-decorator="['settingComponent', {rules: [{ required: true, message: i18n('form.settingComponent','组件','select') }]}]"></rx-input-button>
                                </a-form-item>

                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    v-if="curMenu.menuType!='F'"
                                    :label="i18n('form.icon','图标')"
                                >
                                    <rx-input-icon v-decorator="['iconPc',{rules: [{ required: true, message: i18n('form.icon','图标','select') }]}]" @change="iconChange"></rx-input-icon>
                                    <a-input v-show="false" v-decorator="['iconPic']" ></a-input>
                                </a-form-item>
                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.sequence','显示顺序')"
                                >
                                    <a-input-number
                                        v-decorator="['sn',{initialValue:'1',rules: [{ required: true, message: i18n('msa.sequenceDesc','显示顺序') }]}]"
                                        :placeholder="i18n('form.sequence','显示顺序')"/>
                                </a-form-item>

                                <a-form-item v-if="false && !user.admin"
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('form.share','共享')"
                                >
                                    <a-radio-group name="radioGroup" v-decorator="['share',{initialValue:'N',rules: [{ required: true, message: i18n('form.isShare','请选择是否共享') }]}]">
                                        <a-radio value="Y">{{i18n('form.yes','是')}}</a-radio>
                                        <a-radio value="N">{{i18n('form.no','否')}}</a-radio>
                                    </a-radio-group>
                                </a-form-item>


                            </a-form>
                        </div>
                    </rx-fit>
                </template>
                <template v-if="apiShow">
                    <div style="padding-right: 24px;height: 100%;box-sizing: border-box;">
                        <rx-fit>

                            <div slot="toolheader" foldbtn="false" border="false">
                                <div class="table-operator">

                                        <a-button type="primary"  @click="handleApiAdd">{{$ti18('rxList.newBtn','新建')}}</a-button>
                                        <a-button
                                            v-if="editEnable"
                                            type="primary"
                                            @click="handleApiEdit()"
                                        >{{$ti18('rxList.editBtn','编辑')}}
                                        </a-button>
                                        <a-button type="danger"  @click="delApiByIds()">{{$ti18('rxList.delBtn','删除')}}
                                        </a-button>

                                        <a-button type="primary"  @click="handleApiAddMultiple">{{i18n('apiShow.batchAdd','批量添加')}}</a-button>

                                        <a-button type="primary"  @click="saveBatch">{{$ti18('rxForm.saveBtn','保存')}}</a-button>

                                </div>
                            </div>

                            <rx-grid
                                ref="apiTable"
                                :bordered="true"
                                :dataSource="apiData"
                                :allowRowSelect="true"
                                :show-page="false"
                                :multiSelect="true"
                                :columns="apiColumns"
                                :defaultPageSize="20"
                                data-field="result.data"
                                :pageSizeOptions="['20','30','40']"
                                id-field="id"
                                @selectChange="onSelectApiChange"
                            >
                                <span slot="name" slot-scope="{ text, record }">
                                  {{$i18(record.name)}}
                              </span>
                                <span slot="type" slot-scope="{text}">
                                    {{ getTypeFilter(text) }}
                                </span>

                            </rx-grid>
                        </rx-fit>
                    </div>
                </template>
                <template v-if="apiEditShow">
                    <rx-fit>
                        <div slot="toolfooter" align="right">
                            <div class="footerToolbar">
                                <a-button :loading="confirmApiLoading" @click="handleApiSubmit" type="primary">{{$ti18('rxForm.commitBtn','提交')}}
                                </a-button>
                                <a-button @click="resetApiForm">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                            </div>
                        </div>
                        <div style="padding-bottom: 20px;padding-right: 24px">
                            <a-form>
                                <a-form-item style="display:none;">
                                    <a-input v-model="curApi.appId"/>
                                    <a-input v-model="curApi.menuId"/>
                                </a-form-item>
                                <a-form-item>
                                    <a-button @click="openInterface">{{i18n('apiShow.selectApi','选择接口')}}</a-button>
                                </a-form-item>
                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('apiShow.apiName','接口名称')"
                                >
                                    <rx-input-i18n v-if="apiEditNameShow" :key="apiEditKey"  :isDecorator="true"
                                                   v-model="curApi.name"/>
                                </a-form-item>
                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('apiShow.apiUrl','接口路径')"
                                >
                                    <a-input v-model="curApi.url"/>
                                </a-form-item>

                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('apiShow.apiType','接口类型')"
                                >
                                    <a-select v-model="curApi.type">
                                        <a-select-option value="R">{{i18n('apiShow.read','读')}}</a-select-option>
                                        <a-select-option value="W">{{i18n('apiShow.write','写')}}</a-select-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item
                                    :label-col="{ span: 9 }" :wrapper-col="{ span:15}"
                                    :label="i18n('apiShow.method','接口使用方法')"
                                >
                                    <a-select v-model="curApi.method">
                                        <a-select-option value="GET">GET</a-select-option>
                                        <a-select-option value="POST">POST</a-select-option>
                                        <a-select-option value="PUT">PUT</a-select-option>
                                        <a-select-option value="DEL">DELETE</a-select-option>
                                    </a-select>
                                </a-form-item>
                            </a-form>
                        </div>
                    </rx-fit>
                </template>

            </a-drawer>
        </div>
    </rx-layout>
</template>

<script>
import {Tree} from 'ant-design-vue'

import SysMenuApi from '@/api/system/core/sysMenu';
import SysAppApi from '@/api/system/core/sysApp'
import userState  from "@/assets/js/userState";

import {Util, BaseList, RxLayout, RxGrid, RxFit,RxInputI18n,RxInputButton,Dialog} from "@lowcode/jpaas-common-lib"
import SysAppEdit from "./SysAppEdit";
import SysAppAllMenu from "./SysAppAllMenu";
import SysInterface from "./SysInterface";
import AFormItem from "ant-design-vue/es/form/FormItem";
import rxInputIcon from '@/components/rxComponent/rx-input-icon';
import SysMenuInstEdit from "./SysMenuInstEdit"
import {mapMutations} from "vuex";
import exportApp from "@/views/modules/share/exportApp";
import switchExport from "@/utils/switchExport";
import CalendarViewDialog from "@/views/modules/form/core/dialog/CalendarViewDialog";
import menuStyleDialog from "@/views/modules/system/core/dialog/menuStyleDialog.vue";
export default {
    name: 'SysMenuList',
    mixins: [BaseList, userState,switchExport],
    components: {
        AFormItem,
        Tree,
        RxLayout,
        RxGrid,
        RxFit,
        rxInputIcon,
        RxInputI18n,
        exportApp,
        RxInputButton
    },
    computed: {
        apiTable() {
            return this.$refs.apiTable;
        }
    },

    data() {
        return {
            //是否是应用
            isApp:false,
            menuKey:"c",
            remarks:"",
            menuNameShow:false,
            apiEditNameShow:false,
            apiEditKey:"i",
            customArr: ['customIcon', 'userCustomIcon','jpaasIcon'],
            drawerTitle: '',
            drawerWidth: '500',
            drawerVisible: false,
            description: this.i18n('list.menuManageDesc','菜单管理'),
            visible: true,
            labelCol: {
                span: 8
            },
            wrapperCol: {
                span: 16
            },
            //显示搜索
            showSearch: false,
            // 查询参数
            queryParam: {},
            curMenu: {
                menuType: "",
                settingType: ""
            },
            curApi: {
                name: "",
                parentId: "",
                url: "",
                method: "",
                appId: "",
                menuType: "I",
                type: ""
            },
            // 表头
            columns: [
                {
                    title: this.i18n('form.name','名称'),
                    dataIndex: 'name',
                    width: 160,
                    scopedSlots: {customRender: 'name'},
                },
                {
                    title: this.i18n('form.menuKey','标识键'),
                    dataIndex: 'menuKey',
                    width: 120
                },
                {
                    title: this.i18n('form.menuType','菜单类型'),
                    dataIndex: 'menuType',
                    width: 80,
                    scopedSlots: {customRender: 'menuType'},
                },
                {
                    dataIndex: 'isExport',
                    slots: { title: 'exportApp' },
                    width: 80,
                    scopedSlots: {customRender: 'isExport'}
                },
                {title: this.$ti18('rxForm.createTime','创建时间'), dataIndex: 'createTime', sorter: true, sortField: 'CREATE_TIME_', width: 120},
                {
                    title: this.$ti18('rxList.action','操作'),
                    dataIndex: 'action',
                    width: 180,
                    scopedSlots: {customRender: 'action'},
                }
            ],
            appList: [],
            menuData: [],
            showTypeOptions: [{label: this.i18n('form.optionUrl','URL访问'), value: 'URL'},
                {label: this.i18n('form.optionFuns','功能面板集（标签）'), value: 'FUNS'},
                {label: this.i18n('form.optionFunsBlock','功能面板集（单页）'), value: 'FUNS_BLOCK'},
                {label: this.i18n('form.optionFun','功能面板'), value: 'FUN'},
                {label: this.i18n('form.optionPopover','弹窗'), value: 'POP_WIN'},
                {label: this.i18n('form.optionWin','新窗口'), value: 'NEW_WIN'},
                {label: this.i18n('form.optionVue','新窗口(vue文件)'), value: 'NEW_PAGE'},
            ],
            isShowType: true,
            data: [],
            pagination: false,
            loading: false,
            // 加载数据方法 必须为 Promise 对象
            selectedRowKeys: [],
            selectedRows: [],
            selectedApiRowKeys: [],
            selectedApiRows: [],
            selectMenuId: '',
            icon: 'smile',
            iconPic: '',
            iconPc: '',
            sysAppAllData: [],
            mdl: {},
            form: this.$form.createForm(this),
            apiForm: this.$form.createForm(this),
            confirmLoading: false,
            confirmApiLoading: false,
            apiColumns: [
                {
                    title: this.i18n('apiShow.apiName','接口名称'),
                    width: 100,
                    dataIndex: 'name',
                    scopedSlots: {
                        customRender: 'name'
                    }
                },
                {
                    title: this.i18n('apiShow.apiUrl','接口路径'),
                    dataIndex: 'url',
                    width: 120,
                },
                {
                    title: this.i18n('apiShow.apiType','接口类型'),
                    dataIndex: 'type',
                    width: 80,
                    scopedSlots: {customRender: 'type'},
                },
                {
                    title: this.i18n('apiShow.method','接口方法'),
                    dataIndex: 'method',
                    width: 80
                },
            ],
            apiData: [],
            apiShow: false,
            apiEditShow: false,
            menuShow: true,
            apiLoading: false,
            apiQueryParam: {},
            curRowId: '',
            appWidthHeight: ['800px', '600px'],
            addEnable: true,
            editEnable: true,
            removeEnable: true,
            parentIdNumber: "",
            parentName: '',

            menuTypeMap: {
                "F": {color: 'deepskyblue', text: this.i18n('form.button','按钮')},
                "C": {color: 'green', text: this.i18n('form.menu','菜单')},
                "I": {color: 'orangered', text: this.i18n('form.api','接口')},
                "R": {color: 'DarkSeaGreen', text: this.i18n('form.router','路由')}
            },
            /**
             * 导出配置
             */
            exportConf:{
                Api:SysMenuApi,
                id:"id"
            },
            //配置类型
            settingTypes:['form','list','customPage','calendar','bpm'],
        }
    },
    created() {
        this.visible = '0';
        //后端菜单配置的情况.
        let self_=this;
        if(!this.curApp.appId){
            SysAppApi.getBackApps().then(res => {
                self_.appList = res.sort((app1,app2)=>{
                    return app1.sn -app2.sn;
                });
                if(self_.appList.length>0){
                    self_.handleSelect([self_.appList[0].appId]);
                }
            })
        }
        else{
            this.isApp = true
            this.handleSelect([this.curApp.appId]);
        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"sysMenu",key);
        },
        i18n2(name,text,key){
            return this.$ti18(name,text,"formBoEntity",key);
        },
        async openMenuStyle(){
            let {appId} = this.curApp;
            let res = await SysAppApi.getById(appId);
            let menuMode = '';
            if(res && res.data){
                menuMode = res.data[0].menuMode
            }
            Util.open({
                title:'菜单风格',
                curVm:this,
                component:menuStyleDialog,
                widthHeight:['600px','440px'],
                data:{
                    menuMode
                }
            },(action,data)=>{
                //在这里保存数据
                if(action){
                    SysAppApi.setMenuStyle({appId,menuMode:data}).then(res=>{
                        this.$message.success('菜单风格切换成功！')
                    })
                }
            })
        },
        exportI18n(name,text,key){
            return this.$ti18(name,text,"appExport",key);
        },
        getStatusFilter(status) {
            const statusMap = {
                '1': this.i18n('form.hide','隐藏'),
                '0': this.i18n('form.display','显示')
            }
            return statusMap[status]
        },
        getTypeFilter(type) {
            const typeMap = {
                'R': this.i18n('apiShow.read','读'),
                'W': this.i18n('apiShow.write','写'),
            }
            return typeMap[type]
        },
        rightClick({event, node}) {
            this.curRowId = node.eventKey;
            const postition = {top: event.clientY, left: event.clientX};
            this.$refs.contextmenu.show(postition);
        },
        addApp() {
            var conf = {
                component: SysAppEdit,
                title: this.i18n('list.addApp','添加应用'),
                widthHeight: this.appWidthHeight,
            };
            this.handleAppEdit(conf);
        },
        editApp() {
            var conf = {
                pkId: this.curRowId,
                component: SysAppEdit,
                title: this.i18n('list.editApp','编辑应用'),
                widthHeight: this.appWidthHeight
            };
            this.handleAppEdit(conf);
        },
        handleAppEdit(conf) {
            var pk = conf.pkId;
            var self_ = this;
            var baseConf = {
                "curVm": self_,
                "data": {
                    "pkId": pk, callback: function (data) {
                        console.info(data);
                    }
                }
            };
            let config = Object.assign(baseConf, conf);
            Util.open(config, function (action) {
                if (action == "ok") {
                    SysAppApi.getById(this.curApp.appId).then(res => {
                        self_.appList = res.data;
                    })
                }
            });
        },
        delApp() {
            let self_ = this;
            this.$confirm({
                title: this.$ti18('rxMsa.actionTips','操作提示'),
                content: this.$ti18('rxMsa.delInfo','您确定...'),
                okText: this.$ti18('rxForm.ackBtn','确认'),
                cancelText: this.$ti18('rxForm.cancelBtn','取消'),
                onOk() {
                    SysAppApi.del({ids: self_.curRowId}).then(res => {
                        if (res.success && res.code == 200) {
                            SysAppApi.getById(this.curApp.appId).then(res => {
                                self_.appList = res.data;
                            })
                        }
                    })
                },
                onCancel() {
                }
            })
        },
        transferAppMenus() {
            var self = this;
            if (this.selectedRowKeys.length==0){
                this.$message.error(this.i18n('transferMenu.selectTips','请选择菜单！'));
                return;
            }
            var conf = {
                component: SysAppAllMenu,
                title: this.i18n('transferMenu.transferTitle','转移到'),
                curVm: self,
                widthHeight: ['400px', '550px'],
                data:{
                    multiSelect:false
                }
            };
            Util.open(conf, function (action,data) {
                if (action != 'ok') {
                    return;
                }
                self.selectedRowKeys = [];
                self.$refs.table.clearSelected()
                var menus = this.getSelectMenu();
                self.moveMenuValid(self.selectedRows,menus[0])
            });
        },
        transportTo(menuId) {
            var self = this;
            var conf = {
                component: SysAppAllMenu,
                title: this.i18n('transferMenu.transferTitle','转移到'),
                curVm: self,
                widthHeight: ['400px', '550px'],
                data:{
                    multiSelect:false
                }
            };
            Util.open(conf, function (action) {
                if (action != 'ok') {
                    return;
                }
                var menus = this.getSelectMenu();
                if (!menus || menus.length == 0) {
                    this.$message.error(this.i18n('transferMenu.selectTips','请选择菜单！'));
                    return;
                }
                SysMenuApi.toMoveMenu({
                    menuId: menuId,
                    targetId: menus[0].id,
                    menuType: menus[0].menuType,
                    ckSubMenus: false
                }).then(res => {
                    if (res.success) {
                        self.loadAppMenus();
                    }
                });
            });
        },
        //操作列点击转移
        transportOneTo(record) {
            var self = this;
            var conf = {
                component: SysAppAllMenu,
                title: this.i18n('transferMenu.transferTitle','转移到'),
                curVm: self,
                widthHeight: ['400px', '550px'],
                data:{
                    multiSelect:false
                }
            };
            Util.open(conf, function (action) {
                if (action != 'ok') {
                    return;
                }
                var menus = this.getSelectMenu();
                if (!menus || menus.length == 0) {
                    this.$message.error(this.i18n('transferMenu.selectTips','请选择菜单！'));
                    return;
                }
                let list = [];
                list.push(record);
                self.moveMenuValid(list,menus[0]);

            });
        },
        moveMenuValid(records, changeTree) {
            var self = this;
            var menuIds = "";
            for (let i = 0; i < records.length; i++) {
                let record = records[i];
                if (record.id == changeTree.id) {
                    this.$message.error( "【" + this.$i18(record.name) + "】" + this.i18n('transferMenu.moveTips11','菜单不能转移给自己！'));
                    return;
                }
                //自己无需操作
                if (record.parentId == changeTree.id ) {
                    this.$message.error( "【" + this.$i18(record.name) + "】" + this.i18n('transferMenu.moveTips1','分类无需转移给自己！'));
                    return;
                }
                if(record.children!=null){
                    for (let children of record.children){
                        //父不可以转到子
                        if (children!=null && children.id==changeTree.id ){
                            this.$message.error("【" + this.$i18(record.name) + "】" + this.i18n('transferMenu.moveTips2','父分类不可以转移到子分类') + "【" + this.$i18(changeTree.name) + "】，" + this.i18n('transferMenu.moveTips3','请先将子分类迁移后再操作！'));
                            return;
                        }
                    }
                }
                menuIds += record.id + ",";
            }
            menuIds = menuIds.substring(0, menuIds.lastIndexOf(","));

            SysMenuApi.toMoveMenu({
                menuId: menuIds,
                targetId: changeTree.id,
                menuType: changeTree.menuType,
                ckSubMenus: false
            }).then(res => {
                if (res.success) {
                    self.loadAppMenus();
                }
            });
        },
        showDrawer(width) {
            this.drawerWidth = width ? width : '500';
            this.drawerVisible = true;
        },
        onClose(e) {
            this.drawerVisible = false;
            this.parentName = '';
            this.selectedRows = [];
            this.curMenu.menuType = [];
            this.apiEditShow=false;
            this.apiEditNameShow=false;
        },
        onChangeStatus(checked) {
            if (checked) {
                this.visible = '0';
            } else {
                this.visible = '1';
            }
        },
        menuTypeChange(e) {
            this.curMenu.menuType = e.target.value;
            this.setShowTypes(e.target.value);
        },
        setShowTypes(val) {
            if (val != 'F' && val != 'R') {
                this.isShowType = true;
            } else {
                this.isShowType = false;
            }
        },
        settingTypeChange(e) {
            this.curMenu.settingType = e.target.value
            if(this.curMenu.settingComponent){
                this.form.setFieldsValue({settingComponent:""});
            }
        },
        showTypeChange(e) {
            var value = e.target.value;
            if (['URL','POP_WIN','NEW_WIN','NEW_PAGE'].includes(value)) {
                if (!this.curMenu.settingType) {
                    this.curMenu.settingType = "custom";
                }
            } else {
                this.curMenu.settingType = "";
            }
            this.curMenu.showType = value;
        },
        toggleAdvanced() {
            this.advanced = !this.advanced
        },
        //重置
        resetForm(values) {
            if (values.parentId && values.parentId != "") {
                var menuType = values.menuType;
                this.curMenu = {menuType: menuType, showType: "URL", settingType: "custom"};
                this.handleAdd(this.selectedRows);
            } else {
                this.handleNew();
            }
        },
        //重置
        resetApiForm() {
            this.showDrawer();
            this.drawerTitle = this.i18n('list.newApiTitle','新建接口');
            this.menuShow = false;
            this.menuNameShow=false;
            this.remarks=""
            this.apiEditShow = true;
            this.curApi = {menuId: this.selectMenuId, appId: this.selectAppId};
        },
        //新增
        handleAdd(record) {
            let self_=this;
            this.apiShow = false;
            this.showDrawer();
            this.drawerTitle = this.i18n('list.addSubMenu','新增子菜单');
            this.menuShow = true;
            if (record.id) {
                var parentId = record.id;
            } else {
                var parentId = record[0].id;
            }
            if (this.curMenu.menuType == "") {
                this.curMenu = {menuType: "C", showType: "URL", settingType: "custom"};
                this.setShowTypes(this.curMenu.menuType);
            }
            this.form.resetFields();
            if (record.name == undefined) {
                this.parentName = this.selectedRows[0].name;
            } else {
                this.parentName = record.name;
            }
            this.selectedRows.push(record);
            setTimeout(() => {
                self_.form.setFieldsValue({
                    menuType: this.curMenu.menuType,
                    parentId: parentId,
                    appId: this.selectAppId,
                    showType: this.curMenu.showType,
                    settingType: this.curMenu.settingType
                });
                self_.menuKey = 'c'+Util.randomId();
                self_.remarks="";
                self_.menuNameShow=true;

            }, 100);
        },
        handleApiAdd() {
            this.showDrawer();
            this.drawerTitle = this.i18n('list.newApiTitle','新增接口');
            this.apiEditShow = true;
            this.apiShow = false;
            this.apiEditKey = 'i'+Util.randomId();
            this.apiEditNameShow=true;
        },
        handleApiEdit() {
            let rows=this.selectedApiRows;
            if (rows.length==0) {
                this.$message.warn(this.i18n('msa.editTips','请选择接口!'));
                return;
            }
            if (rows.length>1) {
                this.$message.warn(this.i18n('msa.editOneTips','请选择一个接口!'));
                return;
            }
            if (rows[0].isNew) {
                this.$message.warn(this.i18n('msa.isNewTips','此接口还没有保存!'));
                return;
            }
            this.showDrawer();
            this.drawerTitle = this.i18n('list.editApiTitle','编辑接口');
            this.apiEditShow = true;
            this.apiShow = false;
            this.curApi = rows[0];
            this.apiEditKey = 'i'+Util.randomId();
            this.apiEditNameShow=true;
        },
        openApiEdit(record) {

            //let id=record.id;
            this.parentIdNumber="";
            this.showDrawer();
            this.drawerTitle = this.i18n('list.editApiTitle','编辑接口');
            var self_ = this;
            this.apiShow = false;
            this.menuShow = false;
            self_.menuNameShow=false;
            self_.remarks="";
            this.apiEditShow = true;
            SysMenuApi.getInterfaceByMenuId(record.id).then(res => {
                self_.apiData = res;
                self_.curApi=res[0];
                self_.apiEditKey = 'i'+Util.randomId();
                self_.apiEditNameShow=true;
            })
        },
        delApiByIds() {
            if (this.selectedApiRows.length==0) {
                this.$message.error(this.i18n('msa.editTips','请选择接口!'));
                return;
            }
            for(let i=this.apiData.length-1;i>=0;i--){
                if(this.selectedApiRowKeys.includes(this.apiData[i].id)){
                    this.apiData.splice(i,1);
                }
            }
            this.$refs.apiTable.clearSelected();

        },
        handleNew() {
            let self_=this;
            this.apiShow = false;
            this.showDrawer();
            this.drawerTitle = this.i18n('list.newMenuTitle','新建菜单');
            this.menuShow = true;
            this.curMenu = {menuType: "C", showType: "URL", settingType: "custom"};
            this.setShowTypes(this.curMenu.menuType);
            this.form.resetFields();
            setTimeout(() => {
                this.form.setFieldsValue({
                    appId: this.selectAppId,
                    menuType: "C",
                    settingType: "custom",
                    showType: "URL"
                });
                self_.menuKey = 'c'+Util.randomId();
                self_.remarks="";
                self_.menuNameShow=true;
            }, 100);
        },
        handleEdit(record) {
            let self_=this;
            this.apiShow = false;
            this.apiEditShow = false;
            this.apiEditNameShow=false;
            this.showDrawer();
            this.drawerTitle = this.i18n('list.editMenuTitle','编辑菜单');
            this.menuShow = true;
            //从后台加载菜单数据
            if (record.id !== '') {
                SysMenuApi.getSysMenu(record.id).then(resp => {
                    let _data = resp.data;
                    if(_data.showType == "NEW_PAGE"){
                        _data.settingType = "custom" ;
                    }
                    self_.curMenu = _data;
                    self_.setShowTypes(self_.curMenu.menuType);
                    setTimeout(() => {
                        self_.form.setFieldsValue(_data);
                        self_.menuKey = 'c'+Util.randomId();
                        self_.remarks=_data.remarks;
                        self_.menuNameShow=true;
                    }, 100);
                });
            } else {
                this.setShowTypes(record.menuType);
                this.form.setFieldsValue(record)
                self_.menuKey = 'c'+Util.randomId();
                self_.remarks=record.remarks;
                self_.menuNameShow=true;
            }
        },

        handleOk() {
            this.fetch()
        },
        fetch() {
            this.loading = true
            if(this.curApp.appId){
                this.queryParam.Q_APP_ID__S_EQ=this.curApp.appId;
            }
            SysMenuApi.getSysMenuList(Object.assign(this.queryParam)).then(res => {
                this.data = Util.treeData(res.data, 'id')
                this.loading = false
            })
        },
        resetSearch() {
            this.queryParam = {}
            if(this.curApp.appId){
                this.queryParam.Q_APP_ID__S_EQ=this.curApp.appId;
            }
        },
        refreshGrid() {
            this.fetch()
        },
        delByIds(selectedRowKeys) {
            var self = this;
            this.$confirm({
                title: this.$ti18('rxMsa.actionTips','操作提示'),
                content: this.$ti18('rxMsa.delInfo','您确定...'),
                okText: this.$ti18('rxForm.ackBtn','确认'),
                cancelText: this.$ti18('rxForm.cancelBtn','取消'),
                onOk() {
                    var parameter = {"ids": selectedRowKeys.join(",")};
                    SysMenuApi.delSysMenus(parameter).then(res => {
                        self.selectedRowKeys = [];
                        self.loadAppMenus()
                    })
                }
            })
        },
        onSelectChange(selectedRowKeys, selectedRows) {
            this.selectedRowKeys = selectedRowKeys;
            this.selectedRows = selectedRows;
        },
        onSelectApiChange(selectedRowKeys, selectedRows) {
            this.selectedApiRowKeys = selectedRowKeys;
            this.selectedApiRows = selectedRows;
        },
        // 下面是树相关方法
        onExpand(expandedKeys) {
            this.expandedKeys = expandedKeys
            this.autoExpandParent = false
        },
        getParentKey(key, tree) {
            let parentKey
            for (let i = 0; i < tree.length; i++) {
                const node = tree[i]
                if (node.children) {
                    if (node.children.some(item => item.key === key)) {
                        parentKey = node.key
                    } else if (this.getParentKey(key, node.children)) {
                        parentKey = this.getParentKey(key, node.children)
                    }
                }
            }
            return parentKey
        },
        handleSelect(selectedKeys) {
            this.selectAppId = selectedKeys[0];
            this.loadAppMenus();
            this.form.setFieldsValue({appId: this.selectAppId});
        },
        loadAppMenus() {
            this.loading = true;
            SysMenuApi.getAllSysMenuListByAppId({appId: this.selectAppId}).then(res => {
                this.menuData = Util.treeData(res, 'id');
                this.loading = false
            })
        },

        iconChange(icon){
            if(!icon){
                this.iconPic = '';
                this.form.setFieldsValue({'iconPic': ''});
                this.form.setFieldsValue({'iconPc': ''})
            }else{
                var iconJson=JSON.parse(icon);
                this.iconPic = iconJson.icon;
                this.form.setFieldsValue({'iconPic': iconJson.icon});
                this.form.setFieldsValue({'iconPc': JSON.stringify(iconJson)})
            }
        },

        onSelectMenuChange(selectedRowKeys, selectedRows) {
            this.selectedRowKeys = selectedRowKeys
            this.selectedRows = selectedRows
            console.log('handleSaveOk')
        },
        handleApiSubmit(e) {
            let self_=this;
            var closeThis=this;
            this.confirmApiLoading = true;
            SysMenuApi.saveSysMenu(this.curApi).then(res => {
                self_.confirmApiLoading = false;
                self_.apiEditShow = false;
                self_.apiEditNameShow=false;
                if (self_.parentIdNumber==""){
                    closeThis.onClose();
                }else {
                    self_.apiShow = true;
                    self_.apiLoading = true;
                    self_.showDrawer('500');
                    self_.drawerTitle = this.i18n('apiShow.apiList','接口列表');
                    self_.menuShow = false;
                    self_.menuNameShow=false;
                    self_.remarks="";
                    self_.loading = false;
                    self_.curApi.name = "";
                    self_.curApi.url = "";
                    self_.curApi.method = "";
                    self_.curApi.type = "";
                    SysMenuApi.getInterfaceByParent(self_.parentIdNumber).then(res => {
                        self_.apiData = res;
                        self_.selectedApiRows = [];
                    })
                }

            }).catch(() => {
                this.$message.error(this.$ti18('rxMsa.sysError','系统错误'))
            }).finally(() => {
                this.confirmApiLoading = false;
            })
        },
        ...mapMutations({
            setLogined: 'appSetting/setLogined'
        }),
        resetMenu(){
            this.setLogined(false);
        },
        handleSubmit(e) {
            let self_=this;
            let appId = this.curApp.appId
            this.form.validateFields((err, values) => {
                let menuId = values.id;
                let isUpd = false;
                if (menuId) {
                    isUpd = true;
                }
                if (values.menuType === 'R'){
                    values.showType = 'URL'
                }
                if (!err) {
                    this.confirmLoading = true;
                    values.remarks=self_.remarks;
                    if (appId) {
                        values.appId = appId;
                    }
                    SysMenuApi.saveSysMenu(values).then(res => {
                        this.confirmLoading = false;
                        this.drawerVisible = false;
                        self_.resetMenu();
                        self_.loadAppMenus();
                    }).catch(() => {
                        this.$message.error(this.$ti18('rxMsa.sysError','系统错误'))
                    }).finally(() => {
                        this.confirmLoading = false
                    })
                }
            })
        },

        interfaceDefine(record) {

            this.menuShow = false;
            this.menuNameShow=false;
            this.remarks="";
            this.showDrawer();
            this.drawerTitle = this.i18n('list.newApiTitle','新建接口');
            this.apiShow = true;
            this.parentIdNumber = record.id;
            this.curApi.parentId = record.id;
            this.curApi.appId = record.appId;
            var self_ = this;
            SysMenuApi.getInterfaceByParent(record.id).then(res => {
                self_.apiData = res;
            })
        },

        openInterface() {
            var self = this;
            var conf = {
                component: SysInterface,
                title: this.i18n('apiShow.menuApiDef','菜单接口定义'),
                data: {
                    mutilple: 0
                },
                curVm: self,
                widthHeight: ['600px', '700px']
            };
            Util.open(conf, function (action,data) {
                if (action != 'ok') {
                    return;
                }
                Object.assign(self.curApi,data);
            });
        },


        handleApiAddMultiple() {
            var self = this;
            var conf = {
                component: SysInterface,
                title: this.i18n('apiShow.menuApiDef','菜单接口定义'),
                data: {
                    mutilple: 1
                },
                curVm: self,
                widthHeight: ['600px', '700px']
            };
            Util.open(conf, function (action,data) {
                let apiList=self.apiData;
                let tmpAry=[];
                for(let row of data){
                    let tmpRows=apiList.filter(item=>{
                        return item.method==row.method && item.url ==row.url;
                    });
                    //不存在添加。
                    if(tmpRows.length==0){
                        row.id=Util.randomId();
                        row.isNew=true;
                        tmpAry.push(row);
                    }
                }
                apiList.push(...tmpAry);

                self.$refs.apiTable.clearSelected();
            });
        },
        saveBatch(){

            let apiList=this.apiData;
            let appId=this.curApi.appId;
            let parentId=this.curApi.parentId;
            for(let api of apiList){
                delete  api.id;
                api.appId=appId;
                api.parentId=parentId;
                api.menuType= "I";
            }
            let self_=this;
            SysMenuApi.saveBatchSysMenu(apiList,appId,parentId).then(res=>{
                SysMenuApi.getInterfaceByParent(parentId).then(res=>{
                    self_.apiData=res;
                    self_.selectedApiRows=[];
                    self_.selectedRowKeys=[];
                })
            })
        },
        setInstMenu(record){
            var self=this;
            Util.open({
                component:SysMenuInstEdit,
                curVm:this,
                max:true,
                title: this.i18n('list.orgConfTitle','机构菜单个性化配置'),
                data:{
                    menu:record
                }
            },function (action,data){
                if(action!='ok') return;
                record.instConfig=JSON.stringify(data);
                SysMenuApi.saveSysMenu(record).then(res => {
                    self.loadAppMenus();
                })
            });
        },
        openDialog(vm ,curMenu){
            let _self = this;
            if (curMenu.settingType == 'form'){
                Dialog.openSolution({
                    curVm: this,
                    multiSelect: false,
                    widthHeight: ['1000px', '600px'],
                    data: {
                        multiSelect: false,
                        allowTreeType: false
                    }}, function(data) {
                        vm.setVal(data.alias, data.name);
                        let component = data.tree == 1 ? 'modules/form/FormSolutionShow/FormSolutionTreeShow' : 'modules/form/FormSolutionShow/FormSolutionShow'
                        let obj = {
                            component : component,
                            params : JSON.stringify( {formAlias: data.alias}),
                            settingComponent : JSON.stringify({text: data.name,value:data.alias})
                        }
                        _self.form.setFieldsValue(obj);
                })
            }else if(curMenu.settingType == 'list'){
                Dialog.openFormBoListDialog({
                    curVm: this,
                    data: {single: true, isDialog: 'NO',isDataGrant:true},
                    widthHeight: ['1000px', '600px']
                }, function (self, data,pmtAlias) {
                    let row = data[0];
                    vm.setVal(row.key, row.name);
                    let obj = {
                        component : 'modules/form/FormBoListPreview/FormBoListPreview.vue',
                        params : JSON.stringify({listKey: row.key}),
                        settingComponent : JSON.stringify({text: row.name,value:row.key})
                    }
                    _self.form.setFieldsValue(obj);
                })
            }else if (curMenu.settingType == 'customPage'){
                Dialog.openCustomPageDialog({
                    curVm: this,
                    widthHeight: ['1000px', '600px']
                }, function (data) {
                    vm.setVal(data.alias, data.name);
                    let obj = {
                        component : 'modules/form/FormCustomView/FormCustomView',
                        params : JSON.stringify({alias: data.alias}),
                        settingComponent : JSON.stringify({text: data.name,value:data.alias})
                    }
                    _self.form.setFieldsValue(obj);
                })
            }else if (curMenu.settingType == 'calendar'){
                Util.open({
                    component: CalendarViewDialog,
                    curVm: this,
                    widthHeight: ['1000px', '600px'],
                    title: this.i18n('form.calendar','日历视图'),
                    data: {},
                    zIndex:999
                }, function (action,data) {
                    if (action != 'ok') return;
                    vm.setVal(data.key, data.name);
                    let obj = {
                        component : 'modules/form/FormCalendarViewShow/FormCalendarViewShow',
                        params : JSON.stringify({calendarKey: data.key}),
                        settingComponent : JSON.stringify({text: data.name,value:data.key})
                    }
                    _self.form.setFieldsValue(obj);
                });
            }else if (curMenu.settingType == 'bpm'){
                var config = {curVm: this, widthHeight:['950px','700px'],  data: {single:true}};
                Dialog.openBpmDefDialog(config,function (data) {
                    if(data){
                        vm.setVal(data.defId, data.name);
                        let obj = {
                            component : 'modules/bpm/OpenDoc/BpmInstStart',
                            params : JSON.stringify({defId: data.defId}),
                            settingComponent : JSON.stringify({text: data.name,value:data.defId})
                        }
                        _self.form.setFieldsValue(obj);
                    }
                })
            }
        }

    }
}
</script>
<style scoped>
.table-operator button {
    margin-right: 8px;
    margin-bottom: 8px;

}

.footerToolbar {
    padding-right: 24px;
}

.footerToolbar button {
    margin-left: 10px;
}

.rx-table-row-icon {
    overflow: hidden;
    width: auto;
    vertical-align: top;
    line-height: normal;
    margin-top: 1px;
}

.rx-tree-icon {
    display: inline-block;
    float: left;
    font-size: 16px;
    margin-right: 4px;

}

.rx-tree-title {
    white-space: normal;
    overflow: hidden;
}

* >>> .rx-gridBox .ant-table-row-cell-break-word .ant-table-row-indent,
* >>> .rx-gridBox .ant-table-row-cell-break-word .ant-table-row-expand-icon {
    float: left;
    margin-top: 3px;
}
</style>

